#ifndef SOCKS5_ACTION_UDP_H
#define SOCKS5_ACTION_UDP_H
#pragma once

#include <KSockAddress.h>
#include "S5Action.h"

class S5ActionClient;

class S5ActionUdp : public S5Action {
public:
    explicit S5ActionUdp(S5ActionClient *client);
public:
    void associate(S5ActionUdp *peer);
    bool isProxy() const { return !m_unpack; }
    void relay(const void *data, size_t length, const KIAddress *dest);
    void setSourceAddress(const KIAddress &address);
protected:
    bool process(void *data, size_t length, const KIpAddress &src);
protected:
    void abortImp();
    void onError(KDef::SockError type, DWORD error);
    void onReceived(KKey *&key, void *data, size_t length, bool more);
    void onSent(KKey *&key, void *data, size_t length);
private:
    bool            m_unpack;
    KIpAddress      m_addr;
    S5ActionClient *m_client;
    S5ActionUdp *   m_peer;
};

#endif // SOCKS5_ACTION_UDP_H